package com.decent.ejfadmin.apply.dao.provider;

import com.decent.ejfadmin.apply.request.RebateApplyQueryParam;
import com.decent.ejfadmin.common.bean.Page;
import com.decent.ejfadmin.utils.SQLWrapUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;

/**
 * @author zhangchao
 * @date 2018/7/30 16:53
 */
public class RebateApplyDaoProvider {

    public String queryRebateApplyPage(HashMap<String,Object> params){
        StringBuffer sql = new StringBuffer(100);
        RebateApplyQueryParam param = (RebateApplyQueryParam) params.get("param");
        sql.append("select * from yuhuang_sup_rebate_apply where 1=1 ");
        if (StringUtils.isNotBlank(param.getName())){
            sql.append("and name = #{param.name}");
        }
        if (StringUtils.isNotBlank(param.getPhone())){
            sql.append("and phone = #{param.phone}");
        }
        if (null != param.getState()){
            sql.append("and state = #{param.state}");
        }
        Page page = param.getPageUnit();
        return SQLWrapUtils.wrapPage(sql, page.getBeginIndex(), page.getSize());
    }
}
